List only the unique Link Modules associated a Formal Module

Is there a "more direct" way to list only the unique link modules associated with a formal module?

The current implementation I've inherited involves an attribute with the link module name for every object within each module and then a manual manipulation involving exporting to a spreadsheet and applying filters etc. to work out the unique names (usually only about 2 or 3). There has to be an easier way??

I'm guessing I'm not the first person to need this kind of info and hoping someone already has a script buried in a folder somewhere for something like this.
gmtg - Thu Feb 10 11:24:21 EST 2011

Re: List only the unique Link Modules associated a Formal Module
Peter_Albert - Thu Feb 10 11:40:06 EST 2011

The standard DXL tool for this sort of things are Skip lists. If you create a skip list and use the link module name as string key and value, then the Skip list will only contain the unique values. Simple example:

Skip sList = createString
 
string s
 
s = "Hey"
put(sList, s, s)
put(sList, s, s)
s = "Ho"
put(sList, s, s)
put(sList, s, s)
s = "Let's"
put(sList, s, s)
put(sList, s, s)
s = "go"
put(sList, s, s)
put(sList, s, s)
 
for s in sList do {print s " "}

You see, although I am adding each string twice, each second try is ignored and the SKip list only holds the unique values.

Regards,

Peter

Re: List only the unique Link Modules associated a Formal Module
llandale - Thu Feb 10 12:47:21 EST 2011

Are you asking which link modules are associated with any outgoing or incoming link to this module? Or are you asking which LinkSetPairings are associated with this source module?

For the first, you go to every object and plow through every outgoing "Link" or incoming "LinkRef", get the name, and as Albert suggest put it in a Skip list; which just ignores duplicates. For the 2nd, you need to get the folder of the module, plow through all the LinkModuleDescriptors in the folder, ignore the Sources taht don't match your module, then get the LinkModule and likewise dump it into a Skip.

Then as Albert says print the contents of the Skip.

  • Louie

Re: List only the unique Link Modules associated a Formal Module
gmtg - Fri Feb 11 06:38:13 EST 2011

One of those situations where you completely over think the problem and then kick yourself when you get such a simple and effective answer that you know you should have realised yourself if you had taken a moment to step back... Thank you guys!

For what it's worth, here's the very brief dxl I put together on the back of this in case anyone else finds it helpful (no doubt could be optimised but does what I need today):

// Show the unique Link Modules associated with each Formal Module within a Folder/Project
/*
Lists the unique Link Modules used by link direction.

*/

pragma runLim, 0 // Prevent DXL timeout

Item Mods

for Mods in current Folder do // Interchange "Project" & "Folder" to define scope
{
if (type Mods == "Formal") // Ignore Link and Descriptive Modules
{
// Define Skip List related variables
Skip sInList = createString
Skip sOutList = createString
string s

// Define Module related variables
Module m = read(fullName(Mods), false) // Open the Module read-only
Object o
Link l // Use Link data for Out-links
LinkRef lr // Use LinkRef data for In-Links

// Process Outbound Links
print name m " Outbound Link Module Names:" "\n" // For correct ordering of Text in DXL Output, identify Module name being processed before entering loop
for o in m do
{
for l in o -> "*" do
{
put(sOutList, name module l, name module l) // Populate Skip List using Link Module name as key to ignore duplicates and keep to only unqiue values
}
}
for s in sOutList do {print s "\n"} // Print contents of Skip List to DXL Output (under corresponding Module Name and Link Direction text printed previously)
// Process Inbound Links
print name m " Inbound Link Module Names:" "\n" // For correct ordering of Text in DXL Output, identify Module name being processed before entering loop
for o in m do
{
for lr in o <- "*" do
{
put(sInList, name module lr, name module lr) // Populate Skip List using Link Module name as key to ignore duplicates and keep to only unqiue values
}
}
for s in sInList do {print s "\n"} // Print contents of Skip List to DXL Output (under corresponding Module Name and Link Direction text printed previously)

print "\n" // Print a blank line between Modules for ease of reading

// Tidy up
close m
delete(Skip sOutList)
delete(Skip sInList)
}
}

infoBox "Actions Complete - Details printed in DXL Output pane."

Re: List only the unique Link Modules associated a Formal Module
llandale - Fri Feb 11 16:13:44 EST 2011

gmtg - Fri Feb 11 06:38:13 EST 2011
One of those situations where you completely over think the problem and then kick yourself when you get such a simple and effective answer that you know you should have realised yourself if you had taken a moment to step back... Thank you guys!

For what it's worth, here's the very brief dxl I put together on the back of this in case anyone else finds it helpful (no doubt could be optimised but does what I need today):

// Show the unique Link Modules associated with each Formal Module within a Folder/Project
/*
Lists the unique Link Modules used by link direction.

*/

pragma runLim, 0 // Prevent DXL timeout

Item Mods

for Mods in current Folder do // Interchange "Project" & "Folder" to define scope
{
if (type Mods == "Formal") // Ignore Link and Descriptive Modules
{
// Define Skip List related variables
Skip sInList = createString
Skip sOutList = createString
string s

// Define Module related variables
Module m = read(fullName(Mods), false) // Open the Module read-only
Object o
Link l // Use Link data for Out-links
LinkRef lr // Use LinkRef data for In-Links

// Process Outbound Links
print name m " Outbound Link Module Names:" "\n" // For correct ordering of Text in DXL Output, identify Module name being processed before entering loop
for o in m do
{
for l in o -> "*" do
{
put(sOutList, name module l, name module l) // Populate Skip List using Link Module name as key to ignore duplicates and keep to only unqiue values
}
}
for s in sOutList do {print s "\n"} // Print contents of Skip List to DXL Output (under corresponding Module Name and Link Direction text printed previously)
// Process Inbound Links
print name m " Inbound Link Module Names:" "\n" // For correct ordering of Text in DXL Output, identify Module name being processed before entering loop
for o in m do
{
for lr in o <- "*" do
{
put(sInList, name module lr, name module lr) // Populate Skip List using Link Module name as key to ignore duplicates and keep to only unqiue values
}
}
for s in sInList do {print s "\n"} // Print contents of Skip List to DXL Output (under corresponding Module Name and Link Direction text printed previously)

print "\n" // Print a blank line between Modules for ease of reading

// Tidy up
close m
delete(Skip sOutList)
delete(Skip sInList)
}
}

infoBox "Actions Complete - Details printed in DXL Output pane."

Just because I like to show off, you could count the links as well.

//*********************
bool    fPutSkipIncrement(Skip skpList, string KeyValue)
{     // Insert the KeyValue into the Skip list's 'Key'.
        // The 'Data' portion of the Skip is set to 1 for new inserts and is
        //    incremented for already existing 'Key's in the Skip.
        // 'Data' MUST be of type Integer.
        //   (represents the number of references).
        // Return whether this is a first insert for KeyValue into the Skip.
 
        bool    IsNewValue = false
 
        int     NumReferences = 0       // Remains zero if next "find" doesn't find anything:
        if(find(skpList, KeyValue, NumReferences))
             delete(skpList, KeyValue)          // Remove It
        else IsNewValue = true                  // Mark it New
                        // ReInsert new or updated counts
        NumReferences++
        put (skpList, KeyValue, NumReferences)
        return(IsNewValue)
}     // end fPutSkipIncrement()


Use that instead of "put". You don't care about the returned value.
Your "for s in Skip" loops would be replaced with:
for Count in Skip
{ s = (string key Skip)
and then print the s along with the Count.

 

 

  • Louie


Had a "new age thinking" class many years ago. It dealt with the fact that your mind has so much sensory input that its main job is not to notice things, its to obscure things that are not important: the fact that I used incorrect word "ReInsert" probably got by you, and rightfully so. The main idea is that the best way to get information about something is to first set your mind to doing so. I bet you don't know about how many red-brick houses there are in your neighborhood, but now that I mention it you will notice and be able to tell us on Monday. A secondary idea is to get someone else's perspective, as the stuff she blocks out are usually different than the stuff you block out. You get a silly slap-in-the-head Doh! jolt, and go about your business, problem solved. Folks who need that are called "Humans", those that don't are called "Liars". lol

OK, this is a Yankee thing, probably not a Euro thing: Ever notice those occasional blue reflectors in the streets? Now many of you indeed know their exact particular purpose. But many folks who did not know what they are for are going to notice now just because I got them thinking about it, and will be able to tell us on Monday, after they go Doh! Its pretty simple concept, set your mind first the information is out there.